package com.ruoyi.archive.service.impl;

import com.ruoyi.archive.domain.SSoldierFormInfo;
import com.ruoyi.archive.domain.STransferredCadres;
import com.ruoyi.archive.service.*;
import com.ruoyi.archive.to.CompleteProcess;
import com.ruoyi.archive.to.SoldierFormInfoTo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

/**
 * @program: ruoyi
 * @description:
 * @author: yuxiang
 * @create: 2021-10-12 10:26
 */
@Service
public class CompleteProcessServiceImpl implements ICompleteProcessService {
    @Autowired
    private ISSoldierFormInfoService soldierFormInfoService;
    @Autowired
    private ISTransferredCadresService transferredCadresService;
    @Autowired
    private ISRetiredSoldierService retiredSoldierService;
    @Autowired
    private ISRetiredCadreService retiredCadreService;
    @Autowired
    private ISRetiredNoMilitaryService retiredNoMilitaryService;
    @Autowired
    private ISRetiredRedArmyService retiredRedArmyService;
    @Autowired
    private ISDisabledSoldierService disabledSoldierService;
    @Autowired
    private ISDisabledMilitiamanService disabledMilitiamanService;
    @Autowired
    private ISFamilyOfMartyrService familyOfMartyrService;
    @Autowired
    private ISFamilyOfDutySoldierService familyOfDutySoldierService;
    @Autowired
    private ISFamilyOfIllnessSoldierService familyOfIllnessSoldierService;
    @Autowired
    private ISFamilyOfActiveSoldierService familyOfActiveSoldierService;
    @Autowired
    private ISLivingConditionInfoService livingConditionInfoService;
    @Autowired
    private ISMainAppealService mainAppealService;

    @Transactional(rollbackFor = Exception.class)
    @Override
    public void addCompleteProcess(CompleteProcess completeProcess) {
        // 军人-表单 关联信息保存
        SoldierFormInfoTo soldierFormInfoTo = completeProcess.getSoldierFormInfoTo();
        soldierFormInfoService.saveSoldierForm(soldierFormInfoTo.getSoldierId(), soldierFormInfoTo.getFormIds());

        // 军队转业干部信息
        transferredCadresService.insertSTransferredCadres(completeProcess.getTransferredCadres());
        // 退役士兵信息
        retiredSoldierService.insertSRetiredSoldier(completeProcess.getRetiredSoldier());
        // 军队离休退休干部和士官信息
        retiredCadreService.insertSRetiredCadre(completeProcess.getRetiredCadre());
        // 军队无军籍离休退休职工信息
        retiredNoMilitaryService.insertSRetiredNoMilitary(completeProcess.getRetiredNoMilitary());
        // 退伍红军老战士信息
        retiredRedArmyService.insertSRetiredRedArmy(completeProcess.getRetiredRedArmy());

        // 残疾军人信息
        disabledSoldierService.insertSDisabledSoldier(completeProcess.getDisabledSoldier());
        // 伤残民兵民工信息
        disabledMilitiamanService.insertSDisabledMilitiaman(completeProcess.getDisabledMilitiaman());

        // 烈士遗属
        familyOfMartyrService.insertSFamilyOfMartyr(completeProcess.getFamilyOfMartyr());
        // 因公牺牲军人遗属信息
        familyOfDutySoldierService.insertSFamilyOfDutySoldier(completeProcess.getFamilyOfDutySoldier());
        // 病故军人遗属信息
        familyOfIllnessSoldierService.insertSFamilyOfIllnessSoldier(completeProcess.getFamilyOfIllnessSoldier());
        // 现役军人家属信息
        familyOfActiveSoldierService.insertSFamilyOfActiveSoldier(completeProcess.getFamilyOfActiveSoldier());

        // 生活状况信息
        livingConditionInfoService.insertSLivingConditionInfo(completeProcess.getLivingConditionInfo());
        // 主要诉求信息
        mainAppealService.insertSMainAppeal(completeProcess.getMainAppeal());
    }


}
